<?php

$a ='0.01';
if ($a > 0) echo 'cccc'; 
echo floor(0.02,2);
exit();
define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
// 判断调试模式是否开启缓存
if ((DEBUG_MODE & 2) != 2)
{
    $smarty->caching = true;
}


exit();

if (0) {
    /* 修改进货预计里的进货商品名称 */
    $sql = "SELECT sku FROM egg_ware_purchases";
    $data = $db->getCol($sql);
    foreach ($data as $key => $value) {
        $sql = "SELECT goods_id, goods_attr_id FROM egg_goods_stock WHERE goods_sku = $value";
        $row = $db->getRow($sql);
        $name = $db->getOne("SELECT goods_name FROM egg_goods WHERE goods_id = '{$row['goods_id']}'");
        if (!empty($row['goods_attr_id'])) {
            $name .= "【" . $db->getOne("SELECT attr_value FROM egg_goods_attr WHERE goods_attr_id = '{$row['goods_attr_id']}'") . "】";
        }
        $sql = "UPDATE egg_ware_purchases SET name = '$name' WHERE sku = $value";
        $db->query($sql);
    }
}
if (0) {
    $sql = "insert into `egg_order_goods`(`order_id`,`goods_id`,`goods_name`,`goods_sku`,`product_id`,`goods_number`,`market_price`,`goods_price`,`goods_attr`,`goods_attr_sku`,`send_number`,`is_real`,`extension_code`,`parent_id`,`is_gift`,`goods_attr_id`,`user_name`,`add_time`,`compose_note`,`is_sale`) values('33683','1334','野外素描本110g-A3 （有圈）','2025','0','1',49.00,32.90,'','','0','1','','0','0','','gggitxdx117','1436979661',null,'0')";
    $db->query($sql);
}

/* 导出所有分类 */
if (0) {
    // 文件标签
    header("Content-type: application/vnd.ms-excel; charset=utf-8");
    Header("Content-Disposition: attachment; filename=cat_list.csv");
    /* 获取所有分类 */
    $data = cat_list(0,0,false);
    $l = 0;
    $x = array();
    foreach ($data as $key => $value) {
        $x[$value['level']] = $value['cat_name'];
        $x[$value['level']+1] = $value['cat_id'];
        $l = $value['level'] + 1;
        echo implode(',', array_slice($x, 0, $l+1)) . "\n";
    }
    exit;
}

/**
 * 转广告图
 */
if (0){
    $sql = "SELECT * FROM egg_ad WHERE position_id IN (27,29,31,33,35,37)";
    $data = $db->getAll($sql);
    foreach ($data as $key => $value) {
        if (!empty($value['ad_code'])) {
            if (copy('./data/afficheimg/' . $value['ad_code'], './ads/201508/' . $value['ad_code'])) {
                $value['position_id'] = 50;
                $value['ad_code'] = 'http://www.eggms.com/ads/201508/' . $value['ad_code'];
                $value['start_time'] = time();
                $value['end_time'] = time()+86400*365;
                $value['ad_name'] = 'PC首页专区热门产品'. ($key + 1);
                unset($value['ad_id']);
                $db->autoExecute('egg_ad', $value);
            }
        }
    }
}


if (0) {
    // 转分类
    $old = array('190','191','192','193','194','195','148','147','149','150','151','152','153','154','155','156','157','158','160','161','163','164','593','207','166','167','168','169','239','237','238','240','241','172','173','174','175','176','179','180','181','182','183','184','185','186','188','209','236');
    $new = array('436','436','436','436','436','436','413','414','415','408','407','409','411','410','412','417','416','418','393','394','396','300','397','404','399','401','402','400','402','401','399','405','403','420','421','422','423','424','427','426','431','432','428','433','430','429','434','425','436');
    foreach ($old as $key => $value) {
        $sql = "UPDATE " . $ecs->table('goods_cat') . " SET cat_id = '" . $new[$key] . "' WHERE cat_id = '$value'";
        $db->query($sql);
        $sql = "UPDATE " . $ecs->table('goods') . " SET cat_id = '" . $new[$key] . "' WHERE cat_id = '$value'";
        $db->query($sql);
    }
}

if (0) {
    // 重计算锁定库存
    $sql = "SELECT goods_id, goods_attr_id, (ag.goods_number * a.valid_number) AS stock FROM " . $ecs->table('activity_goods') . " ag LEFT JOIN " . $ecs->table('activity_stock') . " a ON a.parent_id = ag.parent_id AND a.area_id = 3";
    $list = $db->getAll($sql);
    $sql = "UPDATE " . $ecs->table('goods_stock') . " SET locks_number = 0";
    $db->query($sql);
    foreach ($list as $key => $value) {
        if (!empty($value['stock'])) {
            $sql = "UPDATE " . $ecs->table('goods_stock') . " SET locks_number = '$value[stock]' WHERE goods_id = '$value[goods_id]' AND goods_attr_id = '$value[goods_attr_id]' AND area_id = 3";
            $db->query($sql);
        }
    }
}